/*
 * Powered By XY
 * Since 2020
 */

package com.xy.biz.uc.service.impl;

import com.xy.biz.uc.domain.bo.ResourceBO;
import com.xy.biz.uc.domain.query.ResourceQuery;
import com.xy.biz.uc.manager.ResourceManager;
import com.xy.biz.uc.service.ResourceService;
import com.xy.lang.domain.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;

/**
 * 
 * 
 * @author zsp
 * @date 2020-8-19
 */
@Service
public class ResourceServiceImpl implements ResourceService {

	@Autowired
	private ResourceManager resourceManager;
	
	@Override
	public Result<?> updateResource(ResourceBO resourceBO) {
		resourceBO.setUpdateTime(LocalDateTime.now());
		int affectedRows = resourceManager.updateResource(resourceBO);
		if (affectedRows > 0) {
			return Result.success();
		}
		return Result.ofErrorRowsAffected();
	}
	
	@Override
	public ResourceBO getResource(Long resourceId) {
		return resourceManager.getResource(resourceId);
	}
	
	@Override
	public List<ResourceBO> listResourceById(Collection<Long> collection) {
		return resourceManager.listResourceById(collection);
	}
	
	@Override
	public List<ResourceBO> listResource(ResourceQuery query) {
		return resourceManager.listResource(query);
	}
	
	@Override
	public int countResource(ResourceQuery query) {
		return resourceManager.countResource(query);
	}
	
}
